import 'package:bxultimate/app/theme/app_theme.dart';
import 'package:bxultimate/app/theme/gaps.dart';
import 'package:bxultimate/data/store/config_store.dart';
import 'package:bxultimate/domain/user/OrderDto.dart';
import 'package:bxultimate/resources/assets.dart';
import 'package:bxultimate/widgets/mk_load_image.dart';
import 'package:flutter/material.dart';

class AppOrderItem extends StatefulWidget {
  final OrderDto orderDto;

  const AppOrderItem({super.key, required this.orderDto});

  @override
  State<AppOrderItem> createState() => _AppOrderItemState();
}

class _AppOrderItemState extends State<AppOrderItem> {
  TextStyle textStyle = TextStyle(fontSize: 12, color: Color(0xFF606266));

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(
          left: AppTheme.iDefaultPadding,
          right: AppTheme.iDefaultPadding,
          bottom: AppTheme.iDefaultPadding / 2),
      width: double.infinity,
      padding: EdgeInsets.symmetric(
          vertical: AppTheme.iDefaultPadding / 2,
          horizontal: AppTheme.iDefaultPadding),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(AppTheme.iDefaultPadding),
      ),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Row(
            children: [
              Text(
                '订单号: ${widget.orderDto.id}',
                style: textStyle.copyWith(fontSize: 12),
              ),
            ],
          ),
          Gaps.vGap8,
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Row(
                children: [
                  Padding(
                    padding: EdgeInsets.only(top: 8, right: 8, bottom: 8),
                    child: ClipRRect(
                      borderRadius: BorderRadius.circular(8),
                      child: MkLoadImage(
                        ConfigStore.to.baseFileUrl +
                            widget.orderDto.shop!.shopFacadePhoto!,
                        width: 80,
                      ),
                    ),
                  ),
                  Column(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text(
                        '${widget.orderDto.shop!.name}',
                        style: TextStyle(fontSize: 16),
                      ),
                      Gaps.vGap12,
                      Text("${widget.orderDto.payTimeStr}", style: textStyle),
                    ],
                  ),
                ],
              ),
              Column(
                crossAxisAlignment: CrossAxisAlignment.end,
                children: [
                  Text(
                    '￥ ${widget.orderDto.payAmount}',
                    style: TextStyle(fontSize: 16, color: Colors.redAccent),
                  ),
                  Gaps.vGap12,
                  Text("x1", style: textStyle),
                ],
              )
            ],
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.end,
            crossAxisAlignment: CrossAxisAlignment.end,
            children: [
              Text('共一件商品', style: textStyle),
              Text('合计', style: textStyle),
              Text('￥${widget.orderDto.payAmount}',
                  style: TextStyle(fontSize: 16, color: Colors.redAccent)),
            ],
          )
        ],
      ),
    );
  }
}
